/*
 * AVLtree.h
 *
 *  Created on: 05/12/2012
 *      Author: Maor
 */

#ifndef AVLTREE_H_
#define AVLTREE_H_
template<class T>
class AVLtree {
private:
	Bnode* root;
	int size;
	Bnode& search(int id);
public:
	class Bnode;
	AVLtree();
	const T& find(int id) const;
	bool remove(int id);
	bool insert(int id, const T& value);
	bool update(int id,const T& value);
	Node& getNodesInRange(int low,int high) const;
	Node& getAll() const;
	~AVLtree();
};
template<class T>
class AVLtree<T>::Bnode {
	int key;
	T* value;
	Bnode* leftSon;
	Bnode* rightSon;
	Bnode* father;
	int heightLeft;
	int heightRight;
	int BalanceFactor() const;
	friend class AVLtree;
public:
	Bnode(int key, const T& val, const Bnode& father = NULL);
	~Bnode();
};
#endif /* AVLTREE_H_ */
